'use strict';
var app = getApp();
var HOST_URI = 'https://wxapp.wedots.cn/api/';

var app = getApp();

var AGENDA_INFO_LIST = "conference";
var SEARCH_AGENDA_INFO_LIST = "conference/search";
var EXHIBITION_LIST = "conference/exhibition";

function _obj2uri(obj) {
  obj.access_token = app.globalData.access_token;
  if (app.globalData.openid) {
    obj.openid = app.globalData.openid;
  }

  if (app.globalData.version) {
    obj.v = app.globalData.version;
  }
  return Object.keys(obj).map(function (k) {
    return encodeURIComponent(k) + "=" + encodeURIComponent(obj[k]);
  }).join('&');
}

function _searchAgenda(o = []) {
  return HOST_URI + SEARCH_AGENDA_INFO_LIST + '?' + _obj2uri(o);
}

function _loadAgenda(o = []) {
  return HOST_URI + AGENDA_INFO_LIST + '?' + _obj2uri(o);
}

function _loadExhibition(o=[]){
  return HOST_URI + EXHIBITION_LIST + '?' + _obj2uri(o);
}

module.exports = {
  loadExhibition: _loadExhibition,
  loadAgenda: _loadAgenda,
  searchAgenda:_searchAgenda,
};